using System.Collections.Generic;
using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	public sealed class OracleLpColumnDescriptor
	{
		private bool m_vIsAliased;

		private bool m_vIsHidden;

		private bool m_vIsShowing = true;

		private OracleLpColumnType m_vColumnType;

		private OracleLpPseudoColumnType m_vPseudoColumnType;

		private List<OracleLpBindParameter> m_vBindReferences;

		private OracleLpName m_vColumnName;

		private OracleLpName m_vBaseColumnName;

		private OracleLpName m_vBaseTableName;

		private OracleLpName m_vBaseSchemaName;

		public bool IsAliased
		{
			get
			{
				return m_vIsAliased;
			}
			set
			{
				m_vIsAliased = value;
			}
		}

		public bool IsExpression => m_vColumnType == OracleLpColumnType.Expression;

		public bool IsHidden
		{
			get
			{
				return m_vIsHidden;
			}
			set
			{
				m_vIsHidden = value;
				m_vIsShowing = !m_vIsHidden;
			}
		}

		public bool IsReadOnly => m_vColumnType != OracleLpColumnType.Column;

		public bool IsRowID
		{
			get
			{
				if (m_vColumnType == OracleLpColumnType.PseudoColumn)
				{
					return m_vPseudoColumnType == OracleLpPseudoColumnType.ROWID;
				}
				return false;
			}
		}

		public bool IsShowing
		{
			get
			{
				return m_vIsShowing;
			}
			set
			{
				m_vIsShowing = value;
			}
		}

		public OracleLpColumnType ColumnType
		{
			get
			{
				return m_vColumnType;
			}
			set
			{
				m_vColumnType = value;
			}
		}

		public OracleLpPseudoColumnType PseudoColumnType
		{
			get
			{
				return m_vPseudoColumnType;
			}
			set
			{
				m_vPseudoColumnType = value;
			}
		}

		public List<OracleLpBindParameter> BindReferences => m_vBindReferences;

		public bool HasBindReferences
		{
			get
			{
				if (m_vBindReferences != null)
				{
					return m_vBindReferences.Count != 0;
				}
				return false;
			}
		}

		public OracleLpName ColumnName
		{
			get
			{
				return m_vColumnName;
			}
			set
			{
				m_vColumnName = value;
			}
		}

		public OracleLpName BaseColumnName
		{
			get
			{
				return m_vBaseColumnName;
			}
			set
			{
				m_vBaseColumnName = value;
			}
		}

		public OracleLpName BaseTableName
		{
			get
			{
				return m_vBaseTableName;
			}
			set
			{
				m_vBaseTableName = value;
			}
		}

		public OracleLpName BaseSchemaName
		{
			get
			{
				return m_vBaseSchemaName;
			}
			set
			{
				m_vBaseSchemaName = value;
			}
		}

		internal OracleLpColumnDescriptor()
		{
		}

		internal OracleLpColumnDescriptor(OracleLpColumnDescriptor desc)
		{
			m_vPseudoColumnType = desc.m_vPseudoColumnType;
			m_vIsHidden = desc.m_vIsHidden;
			m_vIsShowing = desc.m_vIsShowing;
			m_vIsAliased = desc.m_vIsAliased;
			m_vColumnType = desc.m_vColumnType;
			m_vColumnName = desc.m_vColumnName;
			m_vBaseTableName = desc.m_vBaseTableName;
			m_vBaseSchemaName = desc.m_vBaseSchemaName;
			m_vBaseColumnName = desc.m_vBaseColumnName;
			m_vBindReferences = desc.m_vBindReferences;
		}

		public void AddBindReference(OracleLpBindParameter bp)
		{
			if (m_vBindReferences == null)
			{
				m_vBindReferences = new List<OracleLpBindParameter>();
			}
			m_vBindReferences.Add(bp);
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder(string.Format("ColumnName: {0}, BaseColumnName: {1}, BaseTableName: {2}, BaseSchemaName: {3}\n", m_vColumnName.DbName, (m_vBaseColumnName == null) ? "null" : (m_vBaseColumnName.DbName ?? "null"), (m_vBaseTableName == null) ? "null" : (m_vBaseTableName.DbName ?? "null"), (m_vBaseSchemaName == null) ? "null" : (m_vBaseSchemaName.DbName ?? "null")));
			if (m_vBindReferences != null)
			{
				stringBuilder.Append("Bind references:\n");
				foreach (OracleLpBindParameter vBindReference in m_vBindReferences)
				{
					stringBuilder.Append(vBindReference.ToString());
				}
			}
			return stringBuilder.ToString();
		}
	}
}
